/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.db;

import java.sql.Date;
import java.sql.Time;

/**
 * Author: Raoux Etienne
 * Student login: jc218934
 * Student number: 12448190
 * Date: Jul 31, 2010
 * Time: 9:46:32 AM
 * email: etienne.raoux@my.jcu.edu.au
 * alt email: jc218934@gmail.com
 */
public class MySQLSyntax
{
    public static String correctSyntax(Object object, Class objectClass)
    {
        if (objectClass == Date.class)
        {
            if (object == null) return "NULL";

            return "'"+object.toString()+"T"+new Time(((Date) object).getTime()).toString()+"'";
        }

        if (objectClass == Time.class)
        {
            if (object == null) return "NULL";
            return "'"+object.toString()+"'";
        }

        if (objectClass == String.class) return "'"+object.toString()+"'";

        return object.toString();
    }
}
